//
//  VistorViewController.swift
//  WeiBo
//
//  Created by tusm on 2017/6/17.
//  Copyright © 2017年 GM. All rights reserved.
//

import UIKit

class VistorViewController: UITableViewController {

    var userLogin = false //UserAccountViewModel.shareUserAccount.isLogin
    
    var visitorView:VisitorView?
    
    override func loadView() {
        
        //super.loadView()
        
        userLogin ? super.loadView() : setupVisitorView()
        
    }
    
    private func setupVisitorView(){
        
        visitorView = VisitorView()
        
        view = visitorView
        
        //view.backgroundColor = UIColor.green
        
        visitorView?.registerButton.addTarget(self, action: #selector(VistorViewController.registerClick), for: .touchUpInside)
        visitorView?.loginButton.addTarget(self, action: #selector(VistorViewController.loginClick), for: .touchUpInside)
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action:#selector(VistorViewController.registerClick))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: .plain, target: self, action: #selector(VistorViewController.loginClick))
        
        
    }
    
    
    //注册按钮监听方法
    func registerClick(){
        print("注册")
    }
    
    //登陆按钮监听方法
    func loginClick(){
        
        let vc = OAuthViewController()
        
        let nav = UINavigationController.init(rootViewController: vc)
        
        present(nav, animated: true, completion: nil)
        
        
    }
}
